home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
64'er 1996 May
/
64er_Magazin_96-05_1996_Markt__Technik_de_Side_A.d64
/
player source
< prev
next >
Wrap
Text File
|
2022-10-26
|
19KB
|
844 lines
;64'er Music Player v.08
;All Coding and Design by THE SYNDROM
;---------------------------------------
*= $0f00
sei
lda #$00
jsr init
rt lda #$42
cmp $d012
bne rt
inc $d020
jsr play
dec $d020
lda $dc01
and #$10
bne rt
jmp $9000
;---------------------------------------
*= $1000
jmp init
jmp play
jmp play2
;---------------------------------------
filtyp .byte $00
filcon .byte $00
filfreql .byte $00
filfreqh .byte $00
volume .byte $00
resonance .byte $00
speed .byte $00
speed1 .byte $00
multi .byte $00
identify .byte $00
fade .byte $00
fadetime .byte $00
filtrs .byte $00
hardval .byte $0f ;(xy: x=8->keep ad
.byte $00 ; x=0-> ad=y)
.byte $00,0,0,0 ;yet empty
.byte $00,0,0,0
.text "-player & music by the "
.text "syndrom!-"
;---------------------------------------
dur .byte $00
durat .byte $00
snd .byte $00
ad .byte $00
sr .byte $00
on .byte $00
vofil .byte $00
.byte $00,0,0,0,0,0,0 ;7 bytes
.byte $00,0,0,0,0,0,0 ;7 bytes
trpos .byte $00
trackl .byte $00
trackh .byte $00
secpos .byte $00
wave .byte $00
filpos .byte $00
pupos .byte $00
.byte $00,0,0,0,0,0,0 ; -"-
.byte $00,0,0,0,0,0,0 ; -"-
andor .byte $00
cont .byte $00
trpose .byte $00
fine .byte $00
wavepos .byte $00
switch .byte $00
nopu .byte $00
.byte $00,0,0,0,0,0,0 ; -"-
.byte $00,0,0,0,0,0,0 ; -"-
vspeed .byte $00
vaddl .byte $00
vaddh .byte $00
svol .byte $00
glideh .byte $00
glidel .byte $00
glfrom .byte $00
.byte $00,0,0,0,0,0,0 ; -"-
.byte $00,0,0,0,0,0,0 ; -"-
glto .byte $00
wvspeed .byte $00
hardon .byte $00
notev .byte $00
wvspeed1 .byte $00
noteok .byte $00
drum .byte $00
.byte $00,0,0,0,0,0,0 ; -"-
.byte $00,0,0,0,0,0,0 ; -"-
pulslo .byte $00
pulshi .byte $00
pulsfrm .byte $00
pulsaddl .byte $00
pulsaddh .byte $00
switch2 .byte $00
cut .byte $00
.byte $00,0,0,0,0,0,0 ; -"-
.byte $00,0,0,0,0,0,0 ; -"-
mark .byte $00
;---------------------------------------
init asl a
asl a
asl a
tay
ldx #$00
txa
initcl sta dur,x ;clear data
inx
cpx #mark-dur
bne initcl
ldx #$00 ;prepare pointers
trfill lda trakk,y
sta trackl,x
lda trakk+1,y
sta trackh,x
lda #9 ;reset voices
sta $d404,x
sta on,x
lda #0
sta ad,x
sta sr,x
lda #$02 ;startvalues
sta durat,x
lda #$ff
sta wvspeed1,x
lda #1
sta hardon,x
sta andor,x
iny
iny
txa
clc
adc #7 ;0-7-14-loop
tax
cpx #21
bne trfill
lda trakk,y
sta speed
clc
adc #1
sta speed1
lda trakk+1,y
sta volume
rts
;---------------------------------------
play lda $f8 ;save used
pha ;zeropage to stack
lda $f9
pha
dec speed1 ;main-speed-control
bpl new1
lda speed
sta speed1
new1 ldx #0
jsr voice
ldx #7
jsr voice
ldx #14
jsr voice
lda fade ;volume-fade
beq nofade ;active ?
dec fadetime
lda fadetime
bne nofade
ftime lda #0 ;direct code
sta fadetime ;accessed
lda volume
clc
adc fade
sta volume
cmp #$ff ;lower stop
beq fadestop
cmp #$10
bne nofade ;upper stop
lda #$0f
sta volume
bne nofade
fadestop lda #0
sta fade
sta volume
nofade lda volume ;permanent
ora filtyp ;controls
sta $d418
lda filcon
ora resonance
sta $d417
lda filfreql
sta $d415
lda filfreqh
sta $d416
pla ;rewrite zero-
sta $f9 ;page
pla
sta $f8
rts
;---------------------------------------
voice lda on,x ;voice active?
bne voion
rts
voion lda speed1 ;new duration-
cmp speed ;frame ?
beq new ;
jmp voice3;hr-check for low
;speeds necessary
new dec durat,x ;new command-
beq new3 ;frame ?
jmp voice3
;---------------------------------------
;track-control-routines
;---------------------------------------
;commands
;$ff xx loop xx
;$fe stop voice
;$fd xx transpose +xx
;$fc xx transpose -xx
;$fb xx fadein xx
;$fa xx fadeout xx
;$ex volume x
;---------------------------------------
new3 lda trackl,x ;set pointers
sta $f8
lda trackh,x
sta $f9
;---------------------------------------
;check track-commands
;---------------------------------------
read ldy trpos,x
lda ($f8),y
bpl nocom ;sector or command?
cmp #$fe ;stop
bne com1
lda #0
sta on,x
rts
com1 cmp #$ff ;end
bne com2
iny
lda ($f8),y
sta trpos,x
tay
jmp read+3
com2 cmp #$fd ;tr+xx
bne com3
iny
lda ($f8),y
dazu sta trpose,x
iny
tya
sta trpos,x
jmp read+3
com3 cmp #$fc ;tr-xx
bne com4
iny
lda ($f8),y
eor #$ff
clc
adc #$01
jmp dazu
com4 cmp #$fb ;fd+xx
bne com5
iny
lda ($f8),y
sta fadetime
sta ftime+1
lda #1
sta fade
jmp dazu+3
com5 cmp #$fa ;fd-xx
bne com6
iny
lda ($f8),y
sta fadetime
sta ftime+1
lda #$ff
sta fade
jmp dazu+3
com6 cmp #$e0
bcc com7
cmp #$f0 ;mvl.x
bcs com7
and #$0f
sta volume
inc trpos,x
com7 jmp read
;---------------------------------------
;Sector-control
;commands $fd.xx dur xx
;$fc.xx snd xx
;$fe cont(---)
;$fb gate
;$fa switch
;$f9 cut
;---------------------------------------
nocom tay ;set pointers
lda seclo,y
sta $f8
lda sechi,y
sta $f9
read3 ldy secpos,x
lda ($f8),y ;command or
cmp #$c0 ;note ?
bcs nnote ;
jmp note
nnote cmp #$ff ;end
bne scom1
inc trpos,x
lda switch,x ;no cut if switch
bne nowrap ;is active
lda #$00
sta wave,x
lda #$ff
sta wvspeed1,x
nowrap lda #0
sta secpos,x
jmp new3
scom1 cmp #$fe ;---
bne scom2
note3 iny
tya
sta secpos,x
lda #1
sta cont,x
jmp note2
scom2 cmp #$fd ;dur.xx
bne scom3
iny
lda ($f8),y
sta dur,x
sta durat,x
dazu4 iny
tya
sta secpos,x
jmp read3+3
scom3 cmp #$fc ;snd.xx
bne scom4
iny
lda ($f8),y
sta snd,x
jmp dazu4
scom4 cmp #$fb ;gate
bne scom5
lda #1
eor andor,x
sta andor,x
jmp note3
scom5 cmp #$fa ;switch
bne scom6
lda #1
eor switch,x
sta switch,x
inc secpos,x
jmp read3
scom6 cmp #$f9 ;cut
bne scom7
lda dur,x
sta durat,x
lda #8 ;resets voice
sta $d404,x ;+ voice routines
sta wave,x ;to save rastertime
lda #$00
sta $d405,x
sta $d406,x
sta ad,x
sta sr,x
lda #$ff
sta wvspeed1,x
lda #1
sta cut,x
inc secpos,x
jmp hrcheck
scom7 ;put future commands
;here
jmp read3
note cmp #$60 ;count notevalue
bcc normal
sec
sbc #$60
normal clc
adc trpose,x
sta notev,x ;new note
sta noteok,x
inc secpos,x
note2
lda dur,x ;previous note
sta durat,x
lda #0
sta cut,x
lda switch,x
bne swon
lda cont,x
bne swon
lda #1
sta andor,x
ldy snd,x ;this frame
lda adtab,y;sets the new
sta ad,x ;adsr-settings
sta $d405,x;= beginning of a
lda srtab,y;new note = max.
sta sr,x ;rastertime
sta $d406,x
lda cont,x
beq noconti
swon jsr play3
jmp nocont
noconti lda wavptab,y
sta wavepos,x
tya
pha
ldy wavepos,x ;sets wave
lda wavetab,y ;(first row)
pha
and #$f7
sta wave,x
sta $d404,x ;check for
pla ;drum-mode
and #$08
sta drum,x
beq nodrum2
lda freqtab,y
sta noteok,x
tay
lda frqhi,y
sta $d401,x
lda #0
sta $d400,x
jmp nonon
nodrum2 lda freqtab,y
clc
adc notev,x
sta noteok,x
tay
lda frqlo,y
clc
adc fine,x
sta $d400,x
lda frqhi,y
adc #0
sta $d401,x
nonon pla
tay
lda efftab,y
and #$0f
sta wvspeed,x
sta wvspeed1,x
inc wavepos,x
lda nopu,x
bne filll
;---------------------------------------
lda pulptab,y ;pulse-routine
tay ;init
clc
adc #1
sta pupos,x
lda pulstab1,y
sta pulshi,x
sta $d403,x
lda pulstab2,y
sta pulslo,x
sta $d402,x
lda #0
sta pulsfrm,x
ldy snd,x
filll lda filptab,y
sta filpos,x
nocont lda #0
sta cont,x
lda hardon,x
beq hrcheck
lda #1
sta andor,x
hrcheck ldy secpos,x ;checking next
hrcheck2 lda ($f8),y ;sectordata for
cmp #$ff ;hardrestart on
bne noend ;or off
beq onyes ;user can manipulate
noend cmp #$60 ;this (onyes/onno)
bcc onyes ;(new sector hr)
cmp #$c0
bcc onno
cmp #$fe
beq onno
cmp #$fb
beq onno
cmp #$f9
beq onno
cmp #$fa
bne swi
lda #1
eor switch,x
sta switch2,x
jmp plus1
swi cmp #$fc
bcc plus1
iny
plus1 iny
bne hrcheck2
onno lda #0
beq hrset
onyes lda #1
hrset sta hardon,x
lda switch2,x
beq ond
lda #0
sta hardon,x
ond
rts
;---------------------------------------
;hard-restart-routine
;---------------------------------------
voice3 lda speed
bne nospeed0
lda durat,x
cmp #$03
bcs nichts
;frame 2+1
frame2 lda hardon,x
beq nichts
jsr play3
lda wave,x
and #$fe
sta $d404,x
lda hardval
bpl hrsett
lda ad,x
hrsett sta $d405,x
lda sr,x
and #$f0
sta $d406,x
rts
nospeed0
lda speed1
cmp #2
bcs nichts
lda durat,x
cmp #1
bne nichts
jmp frame2
nichts jmp play3
;---------------------------------------
; adsr-routines
;---------------------------------------
play2 ldx #$00
jsr play3
ldx #7
jsr play3
ldx #14
;---------------------------------------
play3
;---------------------------------------
;wave-freq-table-handling
;---------------------------------------
wavrout
lda cut,x
beq ton
rts
ton lda wvspeed1,x ;new row ?
cmp #$ff
beq nochnich
dec wvspeed1,x
bpl nochnich
lda wvspeed,x
sta wvspeed1,x
newread ldy wavepos,x
inc wavepos,x
lda wavetab,y
cmp #$91 ;check stop
beq schluss
cmp #$90 ;check loop
bne nextstep
lda freqtab,y
sta wavepos,x
jmp newread
nextstep pha
and #$f7 ;check drummode
sta wave,x
pla
and #$08
sta drum,x
beq nodrum
lda freqtab,y
sta noteok,x
jmp nochnich
nodrum lda freqtab,y
clc
adc notev,x
sta noteok,x
jmp nochnich
schluss lda #$ff ;stop mark
sta wvspeed1,x
nochnich
;---------------------------------------
;pulsroutine
;---------------------------------------
lda pupos,x
tay
lda pulsfrm,x ;new row?
bne nonewset
nochmal lda pulstab1,y
cmp #$90 ;check loop
bne pp1
lda pulstab2,y
sta pupos,x
tay
jmp nochmal
pp1 cmp #$91 ;check stop
beq filli
pp2 sta pulsaddh,x ;count values
lda pulstab2,y
sta pulsaddl,x
lda pulstab2+1,y
sta pulsfrm,x
tya
clc
adc #2
sta pupos,x
nonewset lda pulslo,x
clc ;set values
adc pulsaddl,x
sta pulslo,x
sta $d402,x
lda pulshi,x
adc pulsaddh,x
sta pulshi,x
sta $d403,x
dec pulsfrm,x
;---------------------------------------
;Filterroutine
;---------------------------------------
filli ;still to code
;
;---------------------------------------
;writing the SID-registers
;---------------------------------------
lda wave,x
tay ;if gatebit off by
and #1 ;table, disable
beq nogat ;gate command
tya
and #$fe
ora andor,x
tay
nogat tya
sta $d404,x ;write remaining
lda ad,x ;registers
sta $d405,x
lda sr,x
sta $d406,x
ldy noteok,x
lda drum,x
beq norm
tya
sta $d401,x
lda #0
sta $d400,x
beq witer
norm
lda frqlo,y
clc
adc fine,x
sta $d400,x
lda frqhi,y
adc #0
sta $d401,x
witer
rts
;---------------------------------------
;Tables
;---------------------------------------
frqlo .byte $0c,$1c,$2d,$3e,$47,$66
.byte $7b,$91,$a9,$c3,$dd,$fa
.byte $18,$38,$5a,$7d,$a3,$cc
.byte $f6,$23,$53,$86,$bb,$f4
.byte $30,$70,$b4,$fb,$47,$98
.byte $ed,$47,$a7,$0c,$77,$e9
.byte $61,$e1,$68,$f7,$8f,$30
.byte $da,$8f,$4e,$18,$ef,$d2
.byte $c3,$c3,$d1,$ef,$1f,$60
.byte $b5,$1e,$9c,$31,$df,$a5
.byte $87,$86,$a2,$df,$3e,$c1
.byte $6b,$3c,$39,$63,$be,$4b
.byte $0f,$0c,$45,$bf,$7d,$83
.byte $d6,$79,$73,$c7,$7c,$97
.byte $1e,$18,$8b,$7e,$fa,$06
.byte $ac,$f3,$e6,$8f,$f8,$fc
;---------------------------------------
frqhi .byte $01,$01,$01,$01,$01,$01
.byte $01,$01,$01,$01,$01,$01
.byte $02,$02,$02,$02,$02,$02
.byte $02,$03,$03,$03,$03,$03
.byte $04,$04,$04,$04,$05,$05
.byte $05,$06,$06,$07,$07,$07
.byte $08,$08,$09,$09,$0a,$0b
.byte $0b,$0c,$0d,$0e,$0e,$0f
.byte $10,$11,$12,$13,$15,$16
.byte $17,$19,$1a,$1c,$1d,$1f
.byte $21,$23,$25,$27,$2a,$2c
.byte $2f,$32,$35,$38,$3b,$3f
.byte $43,$47,$4b,$4f,$54,$59
.byte $5e,$64,$6a,$70,$77,$7e
.byte $86,$8e,$96,$9f,$a8,$b3
.byte $bd,$c8,$d4,$e1,$ee,$fd
;---------------------------------------
trakk .word tr1,tr2,tr3
.byte $00;speed
.byte $0f;volume
;---------------------------------------
seclo .byte <s00,<s01,<s02
sechi .byte >s00,>s01,>s02
;---------------------------------------
;commands
;$ff xx loop xx
;$fe stop voice
;$fd xx transpose +xx
;$fc xx transpose -xx
;$fb xx fadein xx
;$fa xx fadeout xx
;$ex volume x
;---------------------------------------
tr1
.byte $fa,$0d,0,0,$fa,0,0,0
.byte $fc,$04
.byte $fb,$0d,0,0,0,0
.byte $fc,$00
.byte $ff,$00
tr2
.byte $01,$ff,$00
tr3
.byte $02,$ff,$00
;---------------------------------------
;commands $fd.xx dur xx
;$fc.xx snd xx
;$fe cont(---)
;$fb gate
;$fa switch
;$f9 cut
;---------------------------------------
s00 .byte $fd,$05
.byte $fc,$00
.byte $10,$fe,$fe,$10,$fe,$1a
.byte $1c,$fe,$1c,$10,$f9,$17
.byte $ff
s01 .byte $fd,$05,$fc,$01
.byte $00,$fe,$00,$00,$fe,$00
.byte $fc,$02
.byte $00,$fe,$00,$00,$fe,$00
.byte $ff
s02 .byte $fd,$05,$fc,$03
.byte $34,$fe,$fe,$fe,$fe,$34
.byte $fb,$fe,$34,$34,$f9,$34
.byte $ff
;---------------------------------------
;instrument data
;---------------------------------------
adtab .byte $02,$00,$02,$00
srtab .byte $aa,$f8,$84,$59
wavptab .byte $00,$04,$0b,$12
pulptab .byte $00,$06,$08,$00
filptab .byte $00,$00,$00,$00
efftab .byte $00,$00,$00,$01;xy
;x=
;y=wvspeed
wavetab .byte $41
.byte $89,$41,$91
.byte $09
.byte $89,$19,$19,$19,$18,$91
.byte $09
.byte $89,$48,$88,$48,$88,$91
.byte $21,$21,$21,$90
freqtab .byte $00
.byte $dd,$00,$00
.byte $00
.byte $dd,$0a,$07,$04,$02,$00
.byte $00
.byte $dd,$0d,$3c,$0a,$3c,$00
.byte $00,$03,$07,$12
pulstab1 .byte $03,$00,$00,$ff,$00,$90
.byte $00,$91
.byte $08,$91
pulstab2 .byte $f0,$20,$20,$e0,$20,$01
.byte $00,$00
.byte $00,$00
;---------------------------------------
;not used yet
;---------------------------------------
commtab .byte $00 ;command
commtab1 .byte $00 ;value
commtab2 .byte $00 ;value
;---------------------------------------